package com.tancire.web.controller.market;

import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.core.page.TableDataInfo;
import com.tancire.common.enums.BusinessType;
import com.tancire.common.utils.SecurityUtils;
import com.tancire.net.domain.CrmCompanyTask;
import com.tancire.net.service.ICrmCompanyTaskService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户推广Controller
 *
 * @author chenchao
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/mkt/task")
public class CrmCompanyTaskMktController extends BaseController {
    @Resource
    private ICrmCompanyTaskService crmCompanyTaskService;

    /**
     * 查询客户推广列表
     */
    @PreAuthorize("@ss.hasPermi('company:user:union')")
    @GetMapping("/list")
    public TableDataInfo list(CrmCompanyTask crmCompanyTask) {
        startPage();
        // 查询当前登录账号的任务
        crmCompanyTask.setCompanyId(SecurityUtils.getUserId());
        List<CrmCompanyTask> list = crmCompanyTaskService.selectCrmCompanyTaskList(crmCompanyTask);
        return getDataTable(list);
    }

    /**
     * 删除客户推广
     */
    @PreAuthorize("@ss.hasPermi('company:user:union')")
    @DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable("id") Long id) {
        return toAjax(crmCompanyTaskService.deleteCompanyTaskById(id));
    }
}
